<template>
  <!--
      作者：luoyiming
      时间：2019-10-24
      描述：统计-会员统计-排行榜
  -->
  <div class="member-rangking">
    <div class="common-form mt30">排行榜</div>
    <div class="d-b-s">
      <div class="flex-1">
        <div class="f16">用户消费榜</div>
        <div class="pt16">
          <ul>
            <li class="d-b-c p-10-0 border-b-d" v-for="(item, index) in dataModel.payRanking" :key="index">
              <div class="d-s-c">
                <span class="key-box">{{ index + 1 }}</span>
                <img class="ml10 photo" v-img-url="item.avatarUrl" :alt="item.nickName" />
                <span class="ml4">{{ item.nickName }}</span>
              </div>
              <div class="red">
                ￥
                <span class="fb" style="cursor: pointer;" @click="ordersClick(item)">{{ item.expend_money }}</span>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="flex-1 p-0-30">
        <div class="f16">积分排行榜</div>
        <div class="pt16">
          <ul>
            <li class="d-b-c p-10-0 border-b-d" v-for="(item, index) in dataModel.pointsRanking" :key="index">
              <div class="d-s-c">
                <span class="key-box">{{ index + 1 }}</span>
                <img class="ml10 photo" v-img-url="item.avatarUrl" :alt="item.nickName" />
                <span class="ml4">{{ item.nickName }}</span>
              </div>
              <div class="orange">
                <span class="fb">{{ item.total_points }}</span>
                积分
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="flex-1">
        <div class="f16">邀请人排行榜</div>
        <div class="pt16">
          <ul>
            <li class="d-b-c p-10-0 border-b-d" v-for="(item, index) in dataModel.inviteRanking" :key="index">
              <div class="d-s-c">
                <span class="key-box">{{ index + 1 }}</span>
                <img class="ml10 photo" v-img-url="item.avatarUrl" :alt="item.nickName" />
                <span class="ml4">{{ item.nickName }}</span>
              </div>
              <div class="blue">
                <span class="fb" @click="refereeClick(item)" style="cursor: pointer;">{{ item.total_invite }}</span>
                人
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>

    <Referee :open_referee.sync="open_referee" :referee_id="open_referee_id" :nickName="nickName"></Referee>
    <Orders :open_orders.sync="open_orders" :user_id= "user_id"  :nickName="nickName"></Orders>

  </div>
</template>

<script>
import Referee from '@/views/user/user/dialog/Referee.vue';
import Orders from "@/views/user/user/dialog/Orders.vue";
export default {
  components: {
    Referee,
    Orders
  },
  data() {
    return {
      open_referee: false,
      open_referee_id: 0,
      nickName: '',
      open_orders: false,
      user_id: 0,
      /*是否正在加载*/
      loading: true
    };
  },
  inject: ['dataModel'],
  created() {},
  methods: {
    refereeClick(item) {
      this.open_referee_id = item.user_id;
      this.nickName = item.nickName == "微信用户" ? "微信用户" + item.user_id : item.nickName;
      this.open_referee = true;
    },
    ordersClick(item) {
      this.user_id = item.user_id;
      this.nickName = item.nickName == "微信用户" ? "微信用户" + item.user_id : item.nickName;
      this.open_orders = true;
    }
  }
};
</script>

<style scoped="scoped">
.member-rangking .key-box {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  text-align: center;
  color: red;
  font-weight: bold;
  line-height: 20px;
}
.member-rangking .photo {
  height: 20px;
  height: 20px;
  border-radius: 50%;
}
</style>
